package com.my.objects;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

/**
 * @description:
 * @author: marshal
 * @date: 2021-08-24 2:15 PM
 */
public class ObjectOutputStreamTest {

    public static void main(String[] args) {
        // 序列化一个对象
        try (var oos = new ObjectOutputStream(new FileOutputStream("file/object_output_stream.txt"))) {
            var p = new Person(20, "Jack");
            oos.writeObject(p);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
